Add DAE initialization support#91
Merged
ChrisRackauckas merged 8 commits intoSciML:masterfrom Mar 20, 2026
Merged
Conversation
This PR adds comprehensive DAE initialization support to ODEInterfaceDiffEq, following the pattern from Sundials.jl. New features: - Support for NoInit, CheckInit, OverrideInit, and DefaultInit algorithms - CheckInit verifies algebraic constraints are satisfied at t0 - OverrideInit uses SciMLBase's initialization system for MTK problems - DefaultInit dispatches to OverrideInit if initialization_data exists, otherwise falls back to CheckInit Implementation: - New initialize.jl file with initialize_dae! methods for ODEInterfaceIntegrator - Modified solve.jl to call initialize_dae! before solving - Supports mass matrix DAEs where algebraic equations have zero rows in M Tests: - Basic DAE initialization tests (Robertson model with mass matrix) - MTK-based initialization tests with @mtkcompile - Tests for missing parameters determined via initialization_eqs - Pendulum DAE example testing constraint satisfaction
DefaultInit now: 1. First runs OverrideInit to compute consistent initial conditions 2. Then runs CheckInit to verify algebraic constraints are satisfied This matches the behavior in Sundials.jl v5.
- Reformat radau/radau5 keyword constructors to match Runic style - Accept AbstractMatrix (not just Matrix) for mass_matrix, converting to full Matrix for ODEInterface. Fixes Diagonal mass matrices from MTK. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
OverrideInit internally solves a NonlinearProblem for DAE initialization. Without NonlinearSolve loaded, there's no default solver dispatch. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use SciMLStructures.canonicalize to update parameters in-place after OverrideInit, so sol.ps[param] reflects the computed values. - Fix pendulum test to use numeric L value instead of symbolic parameter in boolean context. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive DAE initialization support to ODEInterfaceDiffEq, following the pattern from Sundials.jl.
New Features
NoInit,CheckInit,OverrideInit, andDefaultInitalgorithmsCheckInitverifies algebraic constraints are satisfied at t0OverrideInituses SciMLBase's initialization system for ModelingToolkit problemsDefaultInitdispatches toOverrideInitifinitialization_dataexists, otherwise falls back toCheckInitImplementation
initialize.jlfile withinitialize_dae!methods forODEInterfaceIntegratorsolve.jlto callinitialize_dae!before solvingTests
@mtkcompileinitialization_eqsRelated
This follows the pattern established in Sundials.jl for DAE initialization support.